package com.zxy.broker.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.zxy.broker.entity.BrokerEntity;
import com.zxy.broker.service.BrokerService;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.R;



/**
 * 经纪人表
 *
 * @author axy
 * @email sunlightcs@gmail.com
 * @date 2022-04-27 18:48:51
 */
@RestController
@RequestMapping("broker/broker")
@CrossOrigin
public class BrokerController {
    @Autowired
    private BrokerService brokerService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = brokerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bid}")

    public R info(@PathVariable("bid") Integer bid){
		BrokerEntity broker = brokerService.getById(bid);

        return R.ok().put("broker", broker);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody BrokerEntity broker){
		brokerService.save(broker);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BrokerEntity broker){
		brokerService.updateById(broker);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] bids){
		brokerService.removeByIds(Arrays.asList(bids));

        return R.ok();
    }

}
